
#include <iostream>
#include <memory>
#include "Reactor.hpp"
#include "HandlerConnection.hpp"
#include "Connection.hpp"
#include "Listener.hpp"
#include "PackageParse.hpp"
#include "Log.hpp"

//./Reactor_Server port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        return 0;
    }
    EnableScreen();
    uint16_t port = std::stoi(argv[1]);

    std::unique_ptr<Reactor> reactor = std::make_unique<Reactor>(); //先把主服务启动起来
    
    HandlerConnection hc(PackageParse::Parse);
    Listener listener(port, hc);
    reactor->AddConnection(listener.Sockfd(), EPOLLIN | EPOLLET, std::bind(&Listener::Accepter, &listener, std::placeholders::_1), nullptr, nullptr);
    reactor->Dispatcher();


    return 0;
}
